<?php
require_once '_inc.php';

$op = $_GET['op'];

if( $op == 'recommen' ) {
	$id  = intval($_GET['id']);
	$val = !empty($_GET['value']) ? intval($_GET['value']) : 0;
	$sql = "update ".$gDb['prefix']."news set recommen='$val' where id='$id'";
	if($id) { 
		$db->query($sql);
		echo json_encode(array('rsp'=>'success'));
	} else {
		echo json_encode(array('rsp' => 'failt'));
	}
	exit( );
}

$page = !empty($_GET['p']) ? intval($_GET['p']) : 1;
$page = ($page-1)*$gPagesize;
$sql  = "select a.*,b.f_name as catename from ".$gDb['prefix']."news a left join ".$gDb['prefix']."categories b on a.catid=b.f_id order by a.id desc limit $page, $gPagesize";
$tpl->assign( 'page', $page );
$tpl->assign( 'list', $db->fetchrows($sql));
$tpl->assign( 'backUrl', base64_encode( $_SERVER['REQUEST_URI'] ) );
$tpl->display( );
